# -*- encoding=utf8 -*-
import unittest

import logging.handlers
import logging
from parameterized import parameterized


from api.login_api import loginApi
from api.subChoice_api import subChoiceApi
from common.assertUtill import assertUtill
from common.load_json import load_jsona
from config import BASE_DIR


class subChoiceTest(unittest.TestCase):

    path = BASE_DIR + '/data/subChoice_data.json'

    @classmethod
    def setUpClass(cls) -> None:
        resp = loginApi.login("1008611","25166186","aa123321")
        # assertUtill(cls, resp.json(), "0", "success")

        cls.token = resp.json()['result']['userList'][0]['accesstoken']
        cls.userID = resp.json()['result']['userList'][0]['userID']
        cls.schoolID = resp.json()['result']['userList'][0]['schoolID']

    @parameterized.expand(load_jsona(path))
    def test_queryActionDetail(self,desc,parameter,code,statu):

        # init_log_config('info.log')

        resp = subChoiceApi.queryActionDetail(parameter,self.token,self.userID,self.schoolID)

        logging.debug(f'resp:{resp.json()}')

        assertUtill(self, resp.json(), code, statu)
